home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
system
/
bootslow.zip
/
SOURCE.ZIP
/
SLOW.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-08-06
|
7KB
|
373 lines
;
;; SlowDown for self-booting software
;;
;; BOOTSLOW
;;
;; Copyright 1991 Alexander R. Pruss
;;
;; May be freely distributed, modified and used provided that no copyright
;; messages are removed, and this sentence together with the next two are
;; always included in unmodified form. If you like this program a lot, you are
;; invited to show your appreciation by making a tax-deductible donation to
;; the Pro-Life or Anti-Abortion movement, but are under no obligation, moral
;; or otherwise to do so (especially if you disagree with the goals of this
;; movement.) There is no warranty; use at own risk.
;
DefaultSlowdown = 200
StackSize = 1024
include macros.inc
BiSeg segment at 0040h
org 13h
bios_memory dw ?
BiSeg ends
SillySeg segment at 0ABCDh
org 80h
CmdHead db ?
SillySeg ends
ZeroSeg segment at 0
org 8h*4
Inter8 label dword
Inter8l dw ?
Inter8h dw ?
org 13h*4
Inter13 label dword
Inter13l dw ?
Inter13h dw ?
ZeroSeg ends
c segment
org 100h
assume cs:c,ss:NOTHING
StartResident:
ResidentSize = offset EndResident - offset StartResident
ResInK = (ResidentSize+1023)/1024
TOP:
jmp Install
disk_level dw 0
factor dw DefaultSlowdown
old8 label dword
o8l dw ?
o8h dw ?
old13 label dword
o13l dw ?
o13h dw ?
assume ds:NOTHING, es:NOTHING, cs:c
i8h:
cmp cs:disk_level,0
jz SlowDown
GoThru8:
jmp dword ptr cs:old8
SlowDown:
push cx
push ax
mov al,3
mov cx,cs:factor
LoopTop:
mul al
add ax,cs:o8h
sub ax,cs:o8l
mul al
mul al
mul al
loop LoopTop
pop ax
pop cx
jmp GoThru8
i13h:
pushf
inc cs:disk_level
call dword ptr cs:old13
pushf
dec cs:disk_level
popf
retf 2
EndResident:
assume ds:c, es:NOTHING, cs:c
getAXd proc near
L1: xor ax,ax
xor bx,bx
cmp si,cx
jae R1
mov bl,[si]
inc si
cmp bl,'0'
jb L1
cmp bl,'9'
ja L1
sub bl,'0'
mov al,bl
L2: cmp si,cx
jae R1
mov bl,[si]
inc si
cmp bl,'0'
jb R1
cmp bl,'9'
ja R1
sub bl,'0'
mov dx,10
mul dx
add ax,bx
jmp L2
R1: ret
getAXd endp
assume ds:c, es:NOTHING, cs:c
_puts proc near
top:
mov bx,1
mov dx,si
mov ah,WriteHandle
int 21h
ret
_puts endp
DiskCheckNo:
mov disk_check,0
jmp parsetop
OutOfMemory:
Puts NoMem
mov ax,4c10h
int 21h
;;
;; Installation
;;
Install:
assume ds:c
cld
Puts copyright
cmp sp,offset stack_bottom+StackSize
jbe OutOfMemory
mov sp,offset stack_bottom+StackSize
assume es:ZeroSeg
Clear ax
mov es,ax
mov ax,es:bios_memory
sub ax,ResInK ; subtract size of resident module in Kb
mov NewMem,ax ; save new total memory size
mov bx,1024/16
mul bx ; ax is total memory in paragraphs
mov bx,cs
add bx,(stack_bottom-TOP+100h+StackSize+2+15)/16 ; paragraph of end of prog
cmp ax,bx
jb OutOfMemory
sub ax,10h ; resident starts now at ax:0100h
mov NewSeg,ax ; save resident segment
assume ds:SillySeg, es:NOTHING
Clear ch
mov cl,CmdHead
assume ds:c
mov si,81h
add cx,si
parsetop:
cmp si,cx
jae PARSER_DONE
lodsb
cmp al,'d'
jz DiskCheckNo
cmp al,'D'
jz DiskCheckNo
cmp al,'0'
jb parsetop
cmp al,'9'
ja parsetop
dec si
call getAXd
mov factor,AX
PARSER_DONE:
;; Load interrupt table now ;;
mov ax,OpenRDOnly
mov dx,offset filename
int 21h
jc _openerror
mov bx,ax
mov ah,ReadHandle
mov cx,4*256
mov dx,offset itable
int 21h
pushf
mov ah,CloseHandle
int 21h
popf
jnc Nopenerror
_openerror: jmp openerror
_Abort: jmp abort
Nopenerror:
;; Load boot sector ;;
Puts drive_q
g1:
DOSGetch
cmp al,01bh
jz _Abort
or al,TOLOWER
cmp al,'a'
jb g1
cmp al,'z'
ja g1
sub al,'a'
mov bx,offset bootsec
mov cx,1
Clear dx
int 25h
jnc NLowLevelError
jmp LowLevelError
NLowLevelError:
Puts booting
;;
;; We're unstoppable now!
;;
Clear ax
mov es,ax
assume es:ZeroSeg
;; Copy interrupt table
mov si,offset itable
Clear di
mov cx,256*4/2
cli
rep movsw
sti
;;
;; Copy boot sector (es=0000)
;;
mov si,offset bootsec
mov di,BootPos
mov cx,512/2
rep movsw
;;
;; (es=0000)
;; Save original interrupts
;;
push es
pop ds
assume ds:ZeroSeg, es:NOTHING
les ax,dword ptr Inter8
mov cs:o8l,ax
mov cs:o8h,es
les ax,dword ptr Inter13
mov cs:o13l,ax
mov cs:o13h,es
push cs
pop ds
assume ds:c
;;
;; Copy to high memory, adjusting maximum memory available
;;
Clear ax
mov es,ax
assume es:ZeroSeg
mov ax,NewMem
mov es:bios_memory,ax
assume es:NOTHING
mov es,NewSeg
mov cx,(EndResident-StartResident+1)/2
mov si,offset StartResident
mov di,si
rep movsw ; Copy to high memory
;; O.K. The memory is all set up. Just need to put in the interrupt
;; tables
;; es points to the new segment
Clear ax
mov ds,ax
assume ds:ZeroSeg
cli
mov Inter8l,offset i8h
mov Inter8h,es
cmp cs:disk_check,0
jz ND
mov Inter13l,offset i13h
mov Inter13h,es
ND:
sti
;; Well, well, well. All done, almost. Just set the registers and jump.
Clear ax
cli
mov ss,ax
mov sp,BootPos-2
sti
db 0EAh ; Far jump
dw BootPos
dw 0000
;; We're in! ;;
LowLevelError:
Puts ll_error
mov ax,4c01h
int 21h
openerror:
Puts cantopen
mov ax,4c02h
int 21h
abort:
Puts aborted
mov ax,4c00h
int 21h
String copyright, <'Self-Booting Disk Slowdown.', CR,LF, '(C) Copyright 1991 Alexander Pruss.', CR,LF>
String NoMem, <'Not enough memory.', CR,LF>
String cantopen, <'Error reading boot.itb.',CR,LF>
String drive_q, <'Choose DOS drive to boot: (A,B,C,etc.), ESC to abort.', CR,LF>
String aborted, <'Aborted.',CR,LF>
String ll_error, <'Error reading boot sector.',CR,LF>
String booting, <'Booting...',CR,LF>
filename db 'boot.itb',00
disk_check db 1
NewSeg dw ?
NewMem dw ?
bootsec label byte
itable = bootsec+512
stack_bottom = itable+1024+512 ; extra 512 for safety
c ends
end TOP